<%@ page contentType="text/html;charset=UTF-8" session="false" %>
<%@ include file="/WEB-INF/common/includes.jsp" %>
<script type="text/javascript">
	$(function() {
		onFormValidate();
		onClickSrcMore();
	});
	
	function onFormValidate(){
		$('#topicForm').validate({
			rules : {
				title : {
					required : true
				},
				text : {
					minlength : 3,
					required : true
				}
			},
			highlight : function(label) {
				$(label).closest('.control-group').addClass('error');
			},
			success : function(label) {
				$(label).closest('.control-group').addClass('success');
			}
		});
	}
	
	function onClickSrcMore(){
		$("#topicFormSrcNameDiv").hide();
		$("#topicFormSrcUserDiv").hide();
		
		$("#topicFormSrcMoreDiv").click(function() {
			var icon = $(this).find("i");
			if($("#topicFormSrcNameDiv").is(":visible")){
				$(icon).attr("class", "icon-chevron-down");
				$("#topicFormSrcNameDiv").hide();
				$("#topicFormSrcUserDiv").hide();
			}else{
				$(icon).attr("class", "icon-chevron-up");
				$("#topicFormSrcNameDiv").show();
				$("#topicFormSrcUserDiv").show();
			}
		});
	}
</script>


<div class="control-group">
	<form:label path="text" class="control-label">原文</form:label>
	<div class="controls">
		<form:textarea path="text" placeholder="原文"/>
		<form:errors path="text" cssClass="text-error" />
	</div>
</div>
<div class="control-group" id="topicFormSrcMoreDiv" style="cursor: pointer;">
	<div class="controls">
		更多原文描述&nbsp;<i class="icon-chevron-down"></i>
	</div>
</div>
<div class="control-group" id="topicFormSrcNameDiv">
	<form:label path="srcName" class="control-label">原文出处</form:label>
	<div class="controls">
		<form:input path="srcName" cssClass="input-large" placeholder="原文出处"  />
		<form:errors path="srcName" cssClass="text-error" />
	</div>
</div>
<div class="control-group" id="topicFormSrcUserDiv">
	<form:label path="srcUser" class="control-label">原文作者</form:label>
	<div class="controls">
		<form:input path="srcUser" cssClass="input-large" placeholder="原文作者"  />
		<form:errors path="srcUser" cssClass="text-error" />
	</div>
</div>
<hr class="topic-hr" />

<div class="control-group">
	<form:label path="title" cssClass="control-label">标题</form:label>
	<div class="controls">
		<form:input path="title" cssClass="input-large" placeholder="标题"  />
		<form:errors path="title" cssClass="text-error" />
	</div>
</div>
<div class="control-group">
	<form:label path="commentText" class="control-label">我的评价</form:label>
	<div class="controls">
		<form:textarea path="commentText" placeholder="我的评价"/>
		<form:errors path="commentText" cssClass="text-error" />
	</div>
</div>

<c:if test="${not empty imgSId}">
	<div class="control-group">
		<div class="controls">
			<img src="${ctx}/image/${imgSId}" class="img-rounded" style="margin-right:10px;" />
		</div>
	</div>
</c:if>

<div class="control-group">
	<label for="files" class="control-label">选择文件</label>
	<div class="controls">
		<form:input path="files" type="file" style="width:308px;" />
		<form:errors path="files" />
	</div>
</div>
<div class="control-group">
	<form:label path="tags" class="control-label">标签</form:label>
	<div class="controls">
		<form:input path="tags" cssClass="input-large" placeholder="标签" />
		<form:errors path="tags" cssClass="text-error" />
	</div>
</div>
